home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hráč 2004 August
/
Hrac_72_2004-08_dvd.iso
/
dema
/
Rapid Gun
/
rg_setup.exe
/
common
/
image_SepiaTone.fx
< prev
next >
Wrap
Text File
|
2004-04-19
|
3KB
|
95 lines
// LF2 Engine
// (C) 2002-3 7FX
//---------------------------------------------------------------------------
// Desc
string desc : Description = "Image shader, ktery meni zobrazeni na sepia tone.";
// Shader type phase
string type : Type = "image";
//---------------------------------------------------------------------------
// Constant for luminance calculation
const float4 cLum = {0.3f, 0.59f, 0.11f, 1.f};
//---------------------------------------------------------------------------
// Render target texture
texture RT : RenderTargetFSMap;
// Sepia tone
texture1D Sepia
<
string file = "Sepia1D";
>;
//---------------------------------------------------------------------------
sampler sRT = sampler_state
{
Texture = <RT>;
MinFilter = POINT;
MagFilter = POINT;
AddressU = CLAMP;
AddressV = CLAMP;
};
sampler sSepia = sampler_state
{
Texture = <Sepia>;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = CLAMP;
};
//---------------------------------------------------------------------------
// Pixel shader
float4 PS20(float2 uv: TEXCOORD0) : COLOR
{
float4 c = .5;
float4 currFrameSample;
float4 currFrameSampleYIQ;
float4x4 YIQMatrix = { 0.299, 0.587, 0.114,0,
0.596, -0.275, -0.321,0,
0.212, -0.523, 0.311,0,
0,0,0,0};
float4x4 inverseYIQ ={ 1.0000000000000000000, .95568806036115671171, .61985809445637075388, 0,
1.0000000000000000000, -.27158179694405859326, -.64687381613840131330, 0,
1.0000000000000000000, -1.1081773266826619523, 1.7050645599191817149, 0,
0,0,0,0 };
// get sample
currFrameSample = tex2D(sRT, uv);
// convert to YIQ space
currFrameSampleYIQ = mul(YIQMatrix , currFrameSample);
currFrameSampleYIQ.y = 0.2; // convert YIQ color to sepia tone
currFrameSampleYIQ.z = 0.0;
// convert back to RGB
c = mul(inverseYIQ, currFrameSampleYIQ);
return c;
}
//---------------------------------------------------------------------------
float4 PS14(float2 uv: TEXCOORD0) : COLOR
{
float4 currFrameSample = tex2D(sRT, uv);
float fdot = currFrameSample.x*cLum.x + currFrameSample.y*cLum.y + currFrameSample.z*cLum.z;
// read in transfer
return tex1D(sSepia, fdot);
}
//---------------------------------------------------------------------------
technique vs0_ps20
{
pass p0
{
ZEnable = false;
ZWriteEnable = false;
PixelShader = compile ps_2_0 PS20();
}
}
//---------------------------------------------------------------------------
technique vs0_ps14
{
pass p0
{
ZEnable = false;
ZWriteEnable = false;
PixelShader = compile ps_1_4 PS14();
}
}
//---------------------------------------------------------------------------